package com.mall.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.dubbo.mappers.CmsSubjectMapper;
import com.tanhua.model.domain.CmsSubject;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class CmsSubjectApiImpl implements CmsSubjectApi{

    @Autowired
    private CmsSubjectMapper cmsSubjectMapper;

    /**
     * 获取全部商品专题
     * @return
     */
    @Override
    public List<CmsSubject> listAll() {
        return cmsSubjectMapper.selectList(new LambdaQueryWrapper<>());
    }

    @Override
    public Page subjectList(String keyword, Page<CmsSubject> page) {
        LambdaQueryWrapper<CmsSubject> lqw = new LambdaQueryWrapper<>();
        lqw.like(keyword != null,CmsSubject::getTitle,keyword);
        return cmsSubjectMapper.selectPage(page,lqw);
    }
}
